package com.seari.custody.pojo;

import com.seari.custody.constant.MessageConstant;
import org.apache.commons.lang3.StringUtils;

public class MessageBean extends BaseBean {

    private static final long serialVersionUID = -7425693410814580587L;

    private String code;

    private String type;

    private String message;

    private Object data;

    public MessageBean() {
    }

    public static MessageBean success(String message, Object data) {
        return new MessageBean(MessageConstant.SUCCESS, MessageConstant.SUCCESS_TYPE, message, data);
    }

    public static MessageBean success(String message) {
        return success(message, null);
    }
    public static MessageBean fail(String message, Object data) {
        return new MessageBean(MessageConstant.FAIL, MessageConstant.FAIL_TYPE, message, data);
    }
    public static MessageBean fail(String message) {
        return fail(message,null);
    }

    public MessageBean(String code, String type, String message, Object data) {
        this.code = code;
        this.type = type;
        this.message = message;
        this.data = data;
    }

    public MessageBean(String type, String message) {
        this.type = type;
        this.message = message;
    }

    public void appendMessage(String str) {
        if (StringUtils.isBlank(this.message)) {
            this.message = "";
        }
        this.message = this.message + str + "\n";
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
